/****************************************************************
 * Fulguro
 * Copyright (C) 2004 Christophe Clienti
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 ***************************************************************/


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <flgrCoreDispatch.h>
#include <flgrCoreSlideWindow.h>
#include "flgrMorphoKerOp.h"
#include "flgrMorphoAmibes.h"



void flgr1d_erode_resizeable_fgBIT(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, FLGR_Data1D *semap, FLGR_Shape shape) {
  FLGR_DECLARE_FUNCTION;
  flgr1d_raster_slide_structuring_function_fgBIT(datdest, datsrc, semap, shape,flgr1d_get_nhb_minimum_fgBIT);
}
void flgr1d_erode_resizeable_fgUINT8(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, FLGR_Data1D *semap, FLGR_Shape shape) {
   FLGR_DECLARE_FUNCTION;
 flgr1d_raster_slide_structuring_function_fgUINT8(datdest, datsrc, semap, shape,flgr1d_get_nhb_minimum_fgUINT8);
}
void flgr1d_erode_resizeable_fgUINT16(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, FLGR_Data1D *semap, FLGR_Shape shape) {
  FLGR_DECLARE_FUNCTION;
  flgr1d_raster_slide_structuring_function_fgUINT16(datdest, datsrc, semap, shape,flgr1d_get_nhb_minimum_fgUINT16);
}
void flgr1d_erode_resizeable_fgUINT32(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, FLGR_Data1D *semap, FLGR_Shape shape) {
  FLGR_DECLARE_FUNCTION;
  flgr1d_raster_slide_structuring_function_fgUINT32(datdest, datsrc, semap, shape,flgr1d_get_nhb_minimum_fgUINT32);
}
void flgr1d_erode_resizeable_fgINT8(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, FLGR_Data1D *semap, FLGR_Shape shape) {
  FLGR_DECLARE_FUNCTION;
  flgr1d_raster_slide_structuring_function_fgINT8(datdest, datsrc, semap, shape,flgr1d_get_nhb_minimum_fgINT8);
}
void flgr1d_erode_resizeable_fgINT16(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, FLGR_Data1D *semap, FLGR_Shape shape) {
  FLGR_DECLARE_FUNCTION;
  flgr1d_raster_slide_structuring_function_fgINT16(datdest, datsrc, semap, shape,flgr1d_get_nhb_minimum_fgINT16);
}
void flgr1d_erode_resizeable_fgINT32(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, FLGR_Data1D *semap, FLGR_Shape shape) {
  FLGR_DECLARE_FUNCTION;
  flgr1d_raster_slide_structuring_function_fgINT32(datdest, datsrc, semap, shape,flgr1d_get_nhb_minimum_fgINT32);
}
void flgr1d_erode_resizeable_fgFLOAT32(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, FLGR_Data1D *semap, FLGR_Shape shape) {
  FLGR_DECLARE_FUNCTION;
  flgr1d_raster_slide_structuring_function_fgFLOAT32(datdest, datsrc, semap, shape,flgr1d_get_nhb_minimum_fgFLOAT32);
}
void flgr1d_erode_resizeable_fgFLOAT64(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, FLGR_Data1D *semap, FLGR_Shape shape) {
  FLGR_DECLARE_FUNCTION;
  flgr1d_raster_slide_structuring_function_fgFLOAT64(datdest, datsrc, semap, shape,flgr1d_get_nhb_minimum_fgFLOAT64);
}
////////////////////////////////////////////////////////////////////////////
/*! Erode with a scalable neighborhood an image
 *
 *  SE width for each pixel are stored in semap. semap could have one to three channel
 *
 *  - If semap->spp==1 then 
 *      - Channel 1 indicates the width of the square around the shape
 *
 *  @param *datdest : image output
 *  @param *datsrc : image input
 *  @param *semap : maps of the neighborhood size evolution
 *  @param shape : shape
 *  @returns FLGR_RET_OK, ...
 */
//////////////////////////////////////////////////////////////////
FLGR_Ret flgr1d_erode_resizeable(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, FLGR_Data1D *semap, FLGR_Shape shape) {
  FLGR_Ret ret;

  FLGR_DECLARE_FUNCTION;

  if((datdest==NULL) || (datsrc==NULL) || (semap==NULL)){
    POST_ERROR("Null objects!\n");
    return FLGR_RET_NULL_OBJECT;
  }

  if((ret=flgr1d_is_data_same_attributes(datdest,datsrc,__FUNCTION__))!=FLGR_RET_OK) return ret;
  if((ret=flgr1d_is_data_same_length(semap,datdest))!=FLGR_RET_OK) return ret;

  if(semap->type != FLGR_INT32) {
    POST_ERROR("Image SE Map must be represented in fgINT32 format!\n");
    return FLGR_RET_PARAM_UNKNOWN;
  }

  FLGR_DISPATCH_PROCEDURE(datdest->type,flgr1d_erode_resizeable,datdest,datsrc,semap,shape);

}



void flgr1d_dilate_resizeable_fgBIT(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, FLGR_Data1D *semap, FLGR_Shape shape) {
  FLGR_DECLARE_FUNCTION;
  flgr1d_raster_slide_structuring_function_fgBIT(datdest, datsrc, semap, shape,flgr1d_get_nhb_maximum_fgBIT);
}
void flgr1d_dilate_resizeable_fgUINT8(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, FLGR_Data1D *semap, FLGR_Shape shape) {
  FLGR_DECLARE_FUNCTION;
  flgr1d_raster_slide_structuring_function_fgUINT8(datdest, datsrc, semap, shape,flgr1d_get_nhb_maximum_fgUINT8);
}
void flgr1d_dilate_resizeable_fgUINT16(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, FLGR_Data1D *semap, FLGR_Shape shape) {
  FLGR_DECLARE_FUNCTION;
  flgr1d_raster_slide_structuring_function_fgUINT16(datdest, datsrc, semap, shape,flgr1d_get_nhb_maximum_fgUINT16);
}
void flgr1d_dilate_resizeable_fgUINT32(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, FLGR_Data1D *semap, FLGR_Shape shape) {
  FLGR_DECLARE_FUNCTION;
  flgr1d_raster_slide_structuring_function_fgUINT32(datdest, datsrc, semap, shape,flgr1d_get_nhb_maximum_fgUINT32);
}
void flgr1d_dilate_resizeable_fgINT8(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, FLGR_Data1D *semap, FLGR_Shape shape) {
  FLGR_DECLARE_FUNCTION;
  flgr1d_raster_slide_structuring_function_fgINT8(datdest, datsrc, semap, shape,flgr1d_get_nhb_maximum_fgINT8);
}
void flgr1d_dilate_resizeable_fgINT16(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, FLGR_Data1D *semap, FLGR_Shape shape) {
  FLGR_DECLARE_FUNCTION;
  flgr1d_raster_slide_structuring_function_fgINT16(datdest, datsrc, semap, shape,flgr1d_get_nhb_maximum_fgINT16);
}
void flgr1d_dilate_resizeable_fgINT32(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, FLGR_Data1D *semap, FLGR_Shape shape) {
  FLGR_DECLARE_FUNCTION;
  flgr1d_raster_slide_structuring_function_fgINT32(datdest, datsrc, semap, shape,flgr1d_get_nhb_maximum_fgINT32);
}
void flgr1d_dilate_resizeable_fgFLOAT32(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, FLGR_Data1D *semap, FLGR_Shape shape) {
  FLGR_DECLARE_FUNCTION;
  flgr1d_raster_slide_structuring_function_fgFLOAT32(datdest, datsrc, semap, shape,flgr1d_get_nhb_maximum_fgFLOAT32);
}
void flgr1d_dilate_resizeable_fgFLOAT64(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, FLGR_Data1D *semap, FLGR_Shape shape) {
  FLGR_DECLARE_FUNCTION;
  flgr1d_raster_slide_structuring_function_fgFLOAT64(datdest, datsrc, semap, shape,flgr1d_get_nhb_maximum_fgFLOAT64);
}
////////////////////////////////////////////////////////////////////////////
/*! Dilate with a scalable neighborhood an image
 *
 *  SE width for each pixel are stored in semap. semap could have one to three channel
 *
 *  - If semap->spp==1 then 
 *      - Channel 1 indicates the width of the square around the shape
 *
 *  @param *datdest : image output
 *  @param *datsrc : image input
 *  @param *semap : maps of the neighborhood size evolution
 *  @param shape : shape
 *  @returns FLGR_RET_OK, ...
 */
//////////////////////////////////////////////////////////////////
FLGR_Ret flgr1d_dilate_resizeable(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, FLGR_Data1D *semap, FLGR_Shape shape) {
  FLGR_Ret ret;

  FLGR_DECLARE_FUNCTION;

  if((datdest==NULL) || (datsrc==NULL) || (semap==NULL)){
    POST_ERROR("Null objects!\n");
    return FLGR_RET_NULL_OBJECT;
  }

  if((ret=flgr1d_is_data_same_attributes(datdest,datsrc,__FUNCTION__))!=FLGR_RET_OK) return ret;
  if((ret=flgr1d_is_data_same_length(semap,datdest))!=FLGR_RET_OK) return ret;

  if(semap->type != FLGR_INT32) {
    POST_ERROR("Image Maps must be represented in fgINT32 format!\n");
    return FLGR_RET_PARAM_UNKNOWN;
  }


  FLGR_DISPATCH_PROCEDURE(datdest->type,flgr1d_dilate_resizeable,datdest,datsrc,semap,shape);

}




void flgr1d_median_resizeable_fgBIT(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, FLGR_Data1D *semap, FLGR_Shape shape) {
  flgr_no_define_type_function(FLGR_BIT);
}
void flgr1d_median_resizeable_fgUINT8(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, FLGR_Data1D *semap, FLGR_Shape shape) {
  FLGR_DECLARE_FUNCTION;
  flgr1d_raster_slide_structuring_function_fgUINT8(datdest, datsrc, semap, shape,flgr1d_get_nhb_median_fgUINT8);
}
void flgr1d_median_resizeable_fgUINT16(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, FLGR_Data1D *semap, FLGR_Shape shape) {
  FLGR_DECLARE_FUNCTION;
  flgr1d_raster_slide_structuring_function_fgUINT16(datdest, datsrc, semap, shape,flgr1d_get_nhb_median_fgUINT16);
}
void flgr1d_median_resizeable_fgUINT32(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, FLGR_Data1D *semap, FLGR_Shape shape) {
  FLGR_DECLARE_FUNCTION;
  flgr1d_raster_slide_structuring_function_fgUINT32(datdest, datsrc, semap, shape,flgr1d_get_nhb_median_fgUINT32);
}
void flgr1d_median_resizeable_fgINT8(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, FLGR_Data1D *semap, FLGR_Shape shape) {
  FLGR_DECLARE_FUNCTION;
  flgr1d_raster_slide_structuring_function_fgINT8(datdest, datsrc, semap, shape,flgr1d_get_nhb_median_fgINT8);
}
void flgr1d_median_resizeable_fgINT16(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, FLGR_Data1D *semap, FLGR_Shape shape) {
  FLGR_DECLARE_FUNCTION;
  flgr1d_raster_slide_structuring_function_fgINT16(datdest, datsrc, semap, shape,flgr1d_get_nhb_median_fgINT16);
}
void flgr1d_median_resizeable_fgINT32(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, FLGR_Data1D *semap, FLGR_Shape shape) {
  FLGR_DECLARE_FUNCTION;
  flgr1d_raster_slide_structuring_function_fgINT32(datdest, datsrc, semap, shape,flgr1d_get_nhb_median_fgINT32);
}
void flgr1d_median_resizeable_fgFLOAT32(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, FLGR_Data1D *semap, FLGR_Shape shape) {
  FLGR_DECLARE_FUNCTION;
  flgr1d_raster_slide_structuring_function_fgFLOAT32(datdest, datsrc, semap, shape,flgr1d_get_nhb_median_fgFLOAT32);
}
void flgr1d_median_resizeable_fgFLOAT64(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, FLGR_Data1D *semap, FLGR_Shape shape) {
  FLGR_DECLARE_FUNCTION;
  flgr1d_raster_slide_structuring_function_fgFLOAT64(datdest, datsrc, semap, shape,flgr1d_get_nhb_median_fgFLOAT64);
}
////////////////////////////////////////////////////////////////////////////
/*! Compute Median with a scalable neighborhood an image
 *
 *  SE width for each pixel are stored in semap. semap could have one to three channel
 *
 *  - If semap->spp==1 then 
 *      - Channel 1 indicates the width of the square around the shape
 *
 *  @param *datdest : image output
 *  @param *datsrc : image input
 *  @param *semap : maps of the neighborhood size evolution
 *  @param shape : shape
 *  @returns FLGR_RET_OK, ...
 */
//////////////////////////////////////////////////////////////////
FLGR_Ret flgr1d_median_resizeable(FLGR_Data1D *datdest, FLGR_Data1D *datsrc, FLGR_Data1D *semap, FLGR_Shape shape) {
  FLGR_Ret ret;

  FLGR_DECLARE_FUNCTION;

  if((datdest==NULL) || (datsrc==NULL) || (semap==NULL)){
    POST_ERROR("Null objects!\n");
    return FLGR_RET_NULL_OBJECT;
  }

  if((ret=flgr1d_is_data_same_attributes(datdest,datsrc,__FUNCTION__))!=FLGR_RET_OK) return ret;
  if((ret=flgr1d_is_data_same_length(semap,datdest))!=FLGR_RET_OK) return ret;

  if(semap->type != FLGR_INT32) {
    POST_ERROR("Image Maps must be represented in fgINT32 format!\n");
    return FLGR_RET_PARAM_UNKNOWN;
  }

  FLGR_DISPATCH_PROCEDURE(datdest->type,flgr1d_median_resizeable,datdest,datsrc,semap,shape);


}









void flgr2d_erode_resizeable_fgBIT(FLGR_Data2D *datdest, FLGR_Data2D *datsrc, FLGR_Data2D *semap, FLGR_Shape shape) {
  FLGR_DECLARE_FUNCTION;
  flgr2d_raster_slide_structuring_function_fgBIT(datdest, datsrc, semap, shape,flgr2d_get_nhb_minimum_fgBIT);
}
void flgr2d_erode_resizeable_fgUINT8(FLGR_Data2D *datdest, FLGR_Data2D *datsrc, FLGR_Data2D *semap, FLGR_Shape shape) {
  FLGR_DECLARE_FUNCTION;
  flgr2d_raster_slide_structuring_function_fgUINT8(datdest, datsrc, semap, shape,flgr2d_get_nhb_minimum_fgUINT8);
}
void flgr2d_erode_resizeable_fgUINT16(FLGR_Data2D *datdest, FLGR_Data2D *datsrc, FLGR_Data2D *semap, FLGR_Shape shape) {
  FLGR_DECLARE_FUNCTION;
  flgr2d_raster_slide_structuring_function_fgUINT16(datdest, datsrc, semap, shape,flgr2d_get_nhb_minimum_fgUINT16);
}
void flgr2d_erode_resizeable_fgUINT32(FLGR_Data2D *datdest, FLGR_Data2D *datsrc, FLGR_Data2D *semap, FLGR_Shape shape) {
  FLGR_DECLARE_FUNCTION;
  flgr2d_raster_slide_structuring_function_fgUINT32(datdest, datsrc, semap, shape,flgr2d_get_nhb_minimum_fgUINT32);
}
void flgr2d_erode_resizeable_fgINT8(FLGR_Data2D *datdest, FLGR_Data2D *datsrc, FLGR_Data2D *semap, FLGR_Shape shape) {
  FLGR_DECLARE_FUNCTION;
  flgr2d_raster_slide_structuring_function_fgINT8(datdest, datsrc, semap, shape,flgr2d_get_nhb_minimum_fgINT8);
}
void flgr2d_erode_resizeable_fgINT16(FLGR_Data2D *datdest, FLGR_Data2D *datsrc, FLGR_Data2D *semap, FLGR_Shape shape) {
  FLGR_DECLARE_FUNCTION;
  flgr2d_raster_slide_structuring_function_fgINT16(datdest, datsrc, semap, shape,flgr2d_get_nhb_minimum_fgINT16);
}
void flgr2d_erode_resizeable_fgINT32(FLGR_Data2D *datdest, FLGR_Data2D *datsrc, FLGR_Data2D *semap, FLGR_Shape shape) {
  FLGR_DECLARE_FUNCTION;
  flgr2d_raster_slide_structuring_function_fgINT32(datdest, datsrc, semap, shape,flgr2d_get_nhb_minimum_fgINT32);
}
void flgr2d_erode_resizeable_fgFLOAT32(FLGR_Data2D *datdest, FLGR_Data2D *datsrc, FLGR_Data2D *semap, FLGR_Shape shape) {
  FLGR_DECLARE_FUNCTION;
  flgr2d_raster_slide_structuring_function_fgFLOAT32(datdest, datsrc, semap, shape,flgr2d_get_nhb_minimum_fgFLOAT32);
}
void flgr2d_erode_resizeable_fgFLOAT64(FLGR_Data2D *datdest, FLGR_Data2D *datsrc, FLGR_Data2D *semap, FLGR_Shape shape) {
  FLGR_DECLARE_FUNCTION;
  flgr2d_raster_slide_structuring_function_fgFLOAT64(datdest, datsrc, semap, shape,flgr2d_get_nhb_minimum_fgFLOAT64);
}
////////////////////////////////////////////////////////////////////////////
/*! Erode with a scalable neighborhood an image
 *
 *  SE width for each pixel are stored in semap. semap could have one to three channel
 *
 *  - If semap->spp==1 then 
 *      - Channel 1 indicates the width of the square around the shape
 *
 *  - If semap->spp==2 then  
 *      - Channel 1 indicates the width of the rectangle around the shape
 *      - Channel 2 indicates the height of the rectangle around the shape
 *
 *  - If semap->spp==3 then  
 *      - Channel 1 indicates the width of the rectangle around the shape
 *      - Channel 2 indicates the height of the rectangle around the shape
 *      - Channel 3 indicates the rotation angle of the shape [-180,180] degrees
 *
 *  @param *datdest : image output
 *  @param *datsrc : image input
 *  @param *semap : maps of the neighborhood size evolution
 *  @param shape : shape
 *  @returns FLGR_RET_OK, ...
 */
//////////////////////////////////////////////////////////////////
FLGR_Ret flgr2d_erode_resizeable(FLGR_Data2D *datdest, FLGR_Data2D *datsrc, FLGR_Data2D *semap, FLGR_Shape shape) {
  FLGR_Ret ret;

  FLGR_DECLARE_FUNCTION;

  if((datdest==NULL) || (datsrc==NULL) || (semap==NULL)){
    POST_ERROR("Null objects!\n");
    return FLGR_RET_NULL_OBJECT;
  }

  if((ret=flgr2d_is_data_same_attributes(datdest,datsrc,__FUNCTION__))!=FLGR_RET_OK) return ret;
  if((ret=flgr2d_is_data_same_size(semap,datdest))!=FLGR_RET_OK) return ret;

  if(semap->type != FLGR_INT32) {
    POST_ERROR("Image SE Map must be represented in fgINT32 format!\n");
    return FLGR_RET_PARAM_UNKNOWN;
  }

  FLGR_DISPATCH_PROCEDURE(datdest->type,flgr2d_erode_resizeable,datdest,datsrc,semap,shape);

}



void flgr2d_dilate_resizeable_fgBIT(FLGR_Data2D *datdest, FLGR_Data2D *datsrc, FLGR_Data2D *semap, FLGR_Shape shape) {
  FLGR_DECLARE_FUNCTION;
  flgr2d_raster_slide_structuring_function_fgBIT(datdest, datsrc, semap, shape,flgr2d_get_nhb_maximum_fgBIT);
}
void flgr2d_dilate_resizeable_fgUINT8(FLGR_Data2D *datdest, FLGR_Data2D *datsrc, FLGR_Data2D *semap, FLGR_Shape shape) {
  FLGR_DECLARE_FUNCTION;
  flgr2d_raster_slide_structuring_function_fgUINT8(datdest, datsrc, semap, shape,flgr2d_get_nhb_maximum_fgUINT8);
}
void flgr2d_dilate_resizeable_fgUINT16(FLGR_Data2D *datdest, FLGR_Data2D *datsrc, FLGR_Data2D *semap, FLGR_Shape shape) {
  FLGR_DECLARE_FUNCTION;
  flgr2d_raster_slide_structuring_function_fgUINT16(datdest, datsrc, semap, shape,flgr2d_get_nhb_maximum_fgUINT16);
}
void flgr2d_dilate_resizeable_fgUINT32(FLGR_Data2D *datdest, FLGR_Data2D *datsrc, FLGR_Data2D *semap, FLGR_Shape shape) {
  FLGR_DECLARE_FUNCTION;
  flgr2d_raster_slide_structuring_function_fgUINT32(datdest, datsrc, semap, shape,flgr2d_get_nhb_maximum_fgUINT32);
}
void flgr2d_dilate_resizeable_fgINT8(FLGR_Data2D *datdest, FLGR_Data2D *datsrc, FLGR_Data2D *semap, FLGR_Shape shape) {
  FLGR_DECLARE_FUNCTION;
  flgr2d_raster_slide_structuring_function_fgINT8(datdest, datsrc, semap, shape,flgr2d_get_nhb_maximum_fgINT8);
}
void flgr2d_dilate_resizeable_fgINT16(FLGR_Data2D *datdest, FLGR_Data2D *datsrc, FLGR_Data2D *semap, FLGR_Shape shape) {
  FLGR_DECLARE_FUNCTION;
  flgr2d_raster_slide_structuring_function_fgINT16(datdest, datsrc, semap, shape,flgr2d_get_nhb_maximum_fgINT16);
}
void flgr2d_dilate_resizeable_fgINT32(FLGR_Data2D *datdest, FLGR_Data2D *datsrc, FLGR_Data2D *semap, FLGR_Shape shape) {
  FLGR_DECLARE_FUNCTION;
  flgr2d_raster_slide_structuring_function_fgINT32(datdest, datsrc, semap, shape,flgr2d_get_nhb_maximum_fgINT32);
}
void flgr2d_dilate_resizeable_fgFLOAT32(FLGR_Data2D *datdest, FLGR_Data2D *datsrc, FLGR_Data2D *semap, FLGR_Shape shape) {
  FLGR_DECLARE_FUNCTION;
  flgr2d_raster_slide_structuring_function_fgFLOAT32(datdest, datsrc, semap, shape,flgr2d_get_nhb_maximum_fgFLOAT32);
}
void flgr2d_dilate_resizeable_fgFLOAT64(FLGR_Data2D *datdest, FLGR_Data2D *datsrc, FLGR_Data2D *semap, FLGR_Shape shape) {
  FLGR_DECLARE_FUNCTION;
  flgr2d_raster_slide_structuring_function_fgFLOAT64(datdest, datsrc, semap, shape,flgr2d_get_nhb_maximum_fgFLOAT64);
}
////////////////////////////////////////////////////////////////////////////
/*! Dilate with a scalable neighborhood an image
 *
 *  SE width for each pixel are stored in semap. semap could have one to three channel
 *
 *  - If semap->spp==1 then 
 *      - Channel 1 indicates the width of the square around the shape
 *
 *  - If semap->spp==2 then  
 *      - Channel 1 indicates the width of the rectangle around the shape
 *      - Channel 2 indicates the height of the rectangle around the shape
 *
 *  - If semap->spp==3 then  
 *      - Channel 1 indicates the width of the rectangle around the shape
 *      - Channel 2 indicates the height of the rectangle around the shape
 *      - Channel 3 indicates the rotation angle of the shape [-180,180] degrees
 *
 *  @param *datdest : image output
 *  @param *datsrc : image input
 *  @param *semap : maps of the neighborhood size evolution
 *  @param shape : shape
 *  @returns FLGR_RET_OK, ...
 */
//////////////////////////////////////////////////////////////////
FLGR_Ret flgr2d_dilate_resizeable(FLGR_Data2D *datdest, FLGR_Data2D *datsrc, FLGR_Data2D *semap, FLGR_Shape shape) {
  FLGR_Ret ret;

  FLGR_DECLARE_FUNCTION;

  if((datdest==NULL) || (datsrc==NULL) || (semap==NULL)){
    POST_ERROR("Null objects!\n");
    return FLGR_RET_NULL_OBJECT;
  }

  if((ret=flgr2d_is_data_same_attributes(datdest,datsrc,__FUNCTION__))!=FLGR_RET_OK) return ret;
  if((ret=flgr2d_is_data_same_size(semap,datdest))!=FLGR_RET_OK) return ret;

  if(semap->type != FLGR_INT32) {
    POST_ERROR("Image Maps must be represented in fgINT32 format!\n");
    return FLGR_RET_PARAM_UNKNOWN;
  }


  FLGR_DISPATCH_PROCEDURE(datdest->type,flgr2d_dilate_resizeable,datdest,datsrc,semap,shape);

}




void flgr2d_median_resizeable_fgBIT(FLGR_Data2D *datdest, FLGR_Data2D *datsrc, FLGR_Data2D *semap, FLGR_Shape shape) {
  flgr_no_define_type_function(FLGR_BIT);
}
void flgr2d_median_resizeable_fgUINT8(FLGR_Data2D *datdest, FLGR_Data2D *datsrc, FLGR_Data2D *semap, FLGR_Shape shape) {
  FLGR_DECLARE_FUNCTION;
  flgr2d_raster_slide_structuring_function_fgUINT8(datdest, datsrc, semap, shape,flgr2d_get_nhb_median_fgUINT8);
}
void flgr2d_median_resizeable_fgUINT16(FLGR_Data2D *datdest, FLGR_Data2D *datsrc, FLGR_Data2D *semap, FLGR_Shape shape) {
  FLGR_DECLARE_FUNCTION;
  flgr2d_raster_slide_structuring_function_fgUINT16(datdest, datsrc, semap, shape,flgr2d_get_nhb_median_fgUINT16);
}
void flgr2d_median_resizeable_fgUINT32(FLGR_Data2D *datdest, FLGR_Data2D *datsrc, FLGR_Data2D *semap, FLGR_Shape shape) {
  FLGR_DECLARE_FUNCTION;
  flgr2d_raster_slide_structuring_function_fgUINT32(datdest, datsrc, semap, shape,flgr2d_get_nhb_median_fgUINT32);
}
void flgr2d_median_resizeable_fgINT8(FLGR_Data2D *datdest, FLGR_Data2D *datsrc, FLGR_Data2D *semap, FLGR_Shape shape) {
  FLGR_DECLARE_FUNCTION;
  flgr2d_raster_slide_structuring_function_fgINT8(datdest, datsrc, semap, shape,flgr2d_get_nhb_median_fgINT8);
}
void flgr2d_median_resizeable_fgINT16(FLGR_Data2D *datdest, FLGR_Data2D *datsrc, FLGR_Data2D *semap, FLGR_Shape shape) {
  FLGR_DECLARE_FUNCTION;
  flgr2d_raster_slide_structuring_function_fgINT16(datdest, datsrc, semap, shape,flgr2d_get_nhb_median_fgINT16);
}
void flgr2d_median_resizeable_fgINT32(FLGR_Data2D *datdest, FLGR_Data2D *datsrc, FLGR_Data2D *semap, FLGR_Shape shape) {
  FLGR_DECLARE_FUNCTION;
  flgr2d_raster_slide_structuring_function_fgINT32(datdest, datsrc, semap, shape,flgr2d_get_nhb_median_fgINT32);
}
void flgr2d_median_resizeable_fgFLOAT32(FLGR_Data2D *datdest, FLGR_Data2D *datsrc, FLGR_Data2D *semap, FLGR_Shape shape) {
  FLGR_DECLARE_FUNCTION;
  flgr2d_raster_slide_structuring_function_fgFLOAT32(datdest, datsrc, semap, shape,flgr2d_get_nhb_median_fgFLOAT32);
}
void flgr2d_median_resizeable_fgFLOAT64(FLGR_Data2D *datdest, FLGR_Data2D *datsrc, FLGR_Data2D *semap, FLGR_Shape shape) {
  FLGR_DECLARE_FUNCTION;
  flgr2d_raster_slide_structuring_function_fgFLOAT64(datdest, datsrc, semap, shape,flgr2d_get_nhb_median_fgFLOAT64);
}
////////////////////////////////////////////////////////////////////////////
/*! Compute Median with a scalable neighborhood an image
 *
 *  SE width for each pixel are stored in semap. semap could have one to three channel
 *
 *  - If semap->spp==1 then 
 *      - Channel 1 indicates the width of the square around the shape
 *
 *  - If semap->spp==2 then  
 *      - Channel 1 indicates the width of the rectangle around the shape
 *      - Channel 2 indicates the height of the rectangle around the shape
 *
 *  - If semap->spp==3 then  
 *      - Channel 1 indicates the width of the rectangle around the shape
 *      - Channel 2 indicates the height of the rectangle around the shape
 *      - Channel 3 indicates the rotation angle of the shape [-180,180] degrees
 *
 *  @param *datdest : image output
 *  @param *datsrc : image input
 *  @param *semap : maps of the neighborhood size evolution
 *  @param shape : shape
 *  @returns FLGR_RET_OK, ...
 */
//////////////////////////////////////////////////////////////////
FLGR_Ret flgr2d_median_resizeable(FLGR_Data2D *datdest, FLGR_Data2D *datsrc, FLGR_Data2D *semap, FLGR_Shape shape) {
  FLGR_Ret ret;

  FLGR_DECLARE_FUNCTION;

  if((datdest==NULL) || (datsrc==NULL) || (semap==NULL)){
    POST_ERROR("Null objects!\n");
    return FLGR_RET_NULL_OBJECT;
  }

  if((ret=flgr2d_is_data_same_attributes(datdest,datsrc,__FUNCTION__))!=FLGR_RET_OK) return ret;
  if((ret=flgr2d_is_data_same_size(semap,datdest))!=FLGR_RET_OK) return ret;

  if(semap->type != FLGR_INT32) {
    POST_ERROR("Image Maps must be represented in fgINT32 format!\n");
    return FLGR_RET_PARAM_UNKNOWN;
  }

  FLGR_DISPATCH_PROCEDURE(datdest->type,flgr2d_median_resizeable,datdest,datsrc,semap,shape);


}




